#!/bin/bash

PATH_LIB=$OSVC_PATH_COMP/com.replication-manager
PREFIX=OSVC_COMP_SPDC_NET

export SPDC_BRGW=10.0.0.$(printf "%d" $(( $(hostname | grep -o "[0-9]*") )) )

typeset -i r=0

case $1 in
check)
	$OSVC_PYTHON $PATH_LIB/file.py ${PREFIX}_FILE check
	[ $? -eq 1 ] && r=1
	exit $r
	;;
fix)
	typeset -i need_ifup=0
	$OSVC_PYTHON $PATH_LIB/file.py ${PREFIX}_FILE check >/dev/null 2>&1 || need_ifup=1
	$OSVC_PYTHON $PATH_LIB/file.py ${PREFIX}_FILE fix
	[ $? -eq 1 ] && exit 1
	[ $need_ifup -eq 1 ] && ifup br0
	exit 0
	;;
fixable)
	exit 2
	;;
esac
